function(Join output_var list glue)
  set(result "")
  foreach(item ${list})
    string(LENGTH "${result}" len)
    if (${len} EQUAL 0)
      string(APPEND result "${item}")
    else()
      string(APPEND result "${glue}${item}")
    endif()
  endforeach()
  set(${output_var} "${result}" PARENT_SCOPE)
endfunction(Join)